package makabakaquestionnaire.zutsoftware.service.impl;

import makabakaquestionnaire.zutsoftware.entity.ProjectItem;
import makabakaquestionnaire.zutsoftware.mapper.ProjectItemMapper;
import makabakaquestionnaire.zutsoftware.service.ProjectItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProjectItemServiceImpl implements ProjectItemService {
    ProjectItemMapper projectItemMapper;
    @Autowired
    public void setProjectItemMapper(ProjectItemMapper projectItemMapper) {
        this.projectItemMapper = projectItemMapper;
    }

    @Override
    public List<ProjectItem> queryProjectItemByProKey(String projectKey) {
        return projectItemMapper.queryProjectItemByProKey(projectKey);
    }

    @Override
    public Boolean insertProjectItem(ProjectItem projectItem) {
      int n=  projectItemMapper.insertProjectItem(projectItem);
        if (n!=1){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Long getMaxSort(String projectKey) {
        return projectItemMapper.getMaxSort(projectKey);
    }

    @Override
    public ProjectItem queryItemById(Long id) {
        return projectItemMapper.queryItemById(id);
    }

    @Override
    public Boolean updateProject(ProjectItem projectItem) {
        int n=projectItemMapper.updateProject(projectItem);
        if (n!=1){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Boolean deleteItem(Long id) {
        int n=projectItemMapper.deleteItem(id);
        if (n!=1){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Long getMaxId() {
        return projectItemMapper.getMaxId();
    }
}
